Constraint involving 3 indices?

28 views
Skip to first unread message

Andrew Gill

unread,
Feb 21, 2025, 5:36:39 AMFeb 21
to MiniZinc
Again, apologies if this is a newbie question (the upside however is that maybe the solution is quick and simple!)

I want to write:

constraint forall([ x[k] != 2*x[i] + x[j] | i,j,k in 1..10 where i,j < k ]);

but obviously doesn't work. I can do 2 indices but not 3. 

Thanks in advance.

Andrew

Jip Dekker

unread,
Feb 21, 2025, 9:52:39 AMFeb 21
to MiniZinc
The problem to me doesn't seem to be that there are three indices, but rather that your “where” condition is not a boolean expression. You've written “i, j < k”, but the “i,” doesn't make sense. Did you mean “i < j /\ j < k” or perhaps just “j < k”?

Andrew Gill

unread,
Feb 21, 2025, 11:15:17 AMFeb 21
to MiniZinc
Thanks Jip - It really was a newbie question. I think I just wanted “i < k /\ j < k”. Out of interest, is that that same as  “i /\ j < k”?

Mikael Zayenz Lagerkvist

unread,
Feb 21, 2025, 12:07:47 PMFeb 21
to mini...@googlegroups.com, MiniZinc
No, the expression i /\ j < k means that i must be true and that j < k must be true, which is something completely different. In partocular, it depends on if i on its own makes sense as a Boolean expression. 

/Mikael

--
Mikael Zayenz Lagerkvist

On 21 Feb 2025, at 06:45, Andrew Gill <andy.w...@gmail.com> wrote:

Thanks Jip - It really was a newbie question. I think I just wanted “i < k /\ j < k”. Out of interest, is that that same as  “i /\ j < k”?
--
You received this message because you are subscribed to the Google Groups "MiniZinc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to minizinc+u...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/minizinc/62917f1a-faba-4feb-8f95-a7621280add9n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages